<?php

class Application_Model_DbTable_Linestops extends Zend_Db_Table_Abstract
{

    protected $_name = 'linestop';
	
	public function getLineStops($id)
	{
		$_db = Zend_Db_Table::getDefaultAdapter();
		$sql = "SELECT stop.name, stop.latitude, stop.longitude
				FROM stop, linestop
				WHERE stop.id = linestop.stop_id
				AND linestop.line_id = {$id}";
		$statement = $_db->query($sql);
		
		return $statement;
		
	}
	
	
	
	public function addLineStops($id1, $id2)
	{
		$_db = Zend_Db_Table::getDefaultAdapter();
		$sql = "INSERT INTO linestop (line_id,stop_id) VALUES ({$id1},{$id2})";
		$statement = $_db->query($sql);
		
		return $statement;
	}
	
	public function deleteLineStops($id1, $id2)
	{
		$_db = Zend_Db_Table::getDefaultAdapter();
		$sql = "DELETE * FROM linestop
				WHERE linestop.line_id={$id1}
				AND linestop.stop_id = {$id2}";
				
		$statement = $_db->query($sql);
		
		return $statement;
	}

}

